package com.mr.pay.action;

import com.mr.base.domain.Card;
import com.mr.pay.domain.Cust;
import com.mr.pay.service.CustService;
import com.skysz.framework.action.AbstractBaseAction;
import com.skysz.framework.action.ActionResponse;
import com.skysz.framework.action.ActionUtils;
import com.skysz.framework.action.ResponseType;

/**
 * 顾客管理
 * @author zhaow
 */
public class CustAction extends AbstractBaseAction {
	private static final long serialVersionUID = -8225835622148413203L;
	
	private CustService<Cust> custService;
		

	public void setCustService(CustService<Cust> custService) {
		this.custService = custService;
	}




	/**
	 * 新增顾客
	 * @return
	 * @throws Exception
	 */
	public ActionResponse insertCust() throws Exception {
		ActionResponse ar = new ActionResponse(ResponseType.FAILURE);
		
		Long cardId = super.getParameter("card.id", Long.class);
		Card card = new Card();
		card.setId(cardId);
		
		Cust cust = super.creatBean(Cust.class, false);
		cust.setCard(card);
		ActionUtils.setWho(cust);
		this.custService.insertCust(cust);

		//保存成功
		ar.setResponseType(ResponseType.SUCCESS_SAVE);
		return ar;
	}
}
